package it.giulio.oracle;

import java.sql.Connection;
import java.sql.SQLException;

import oracle.jdbc.pool.OracleDataSource;

public class OracleLoggableDataSource extends oracle.jdbc.pool.OracleDataSource {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7412505878090806696L;


    protected OracleDataSource rds;
    protected String rdsName;
	
	public OracleLoggableDataSource() throws SQLException {
	    super();
	}
	
	public OracleLoggableDataSource(OracleDataSource source) throws SQLException {
		rds = source;
	}
	
	public String getRealDataSource() {
		return rdsName;
	}
	
	public void setRealDataSource(String inVar) {
		rdsName = inVar;
	}
	
	public int getLoginTimeout() {
		return rds.getLoginTimeout();
	}

	public void setLoginTimeout(int inVar) {
		rds.setLoginTimeout(inVar);
	}

	public synchronized void close() throws SQLException {
		super.close();
	}
	
	public Connection getConnection() throws SQLException { 
		return new OracleLoggableConnection(rds.getConnection()); // -- OracleLoggable entry point!!! 
	}
	
	public Connection getConnection(String username, String password) throws SQLException {
	    return new OracleLoggableConnection(rds.getConnection(username, password)); // -- OracleLoggable entry point!!!
	}
}